An automatic portable firearm is provided with a magazine in which a number of cartridges are held. The magazine is usually attached to the bottom side of the firearm receiver at the rear part of the barrel. It is desirable that the magazine can be attached and detached with respect to the portable firearm to quickly reload the cartridges. In this case, the portable firearm, as shown in PLT 1, is provided with a magazine lock.